package com.hkbigdata.datagovernance.governance.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hkbigdata.datagovernance.governance.bean.GovernanceAssessTable;
import com.hkbigdata.datagovernance.governance.bean.GovernanceAssessTecOwner;
import com.hkbigdata.datagovernance.governance.mapper.GovernanceAssessTableMapper;
import com.hkbigdata.datagovernance.governance.mapper.GovernanceAssessTecOwnerMapper;
import com.hkbigdata.datagovernance.governance.service.GovernanceAssessTecOwnerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 技术负责人治理考评表 服务实现类
 * </p>
 *
 * @author 
 * @since 2024-01-10
 */
@Service
@DS("mysqlWriting")
public class GovernanceAssessTecOwnerServiceImpl extends ServiceImpl<GovernanceAssessTecOwnerMapper, GovernanceAssessTecOwner> implements GovernanceAssessTecOwnerService {
    @Autowired
    GovernanceAssessTecOwnerMapper governanceAssessTecOwnerMapper;

    @Override
    public void calcAssessByTecOwner(String assessDate) {
//        重跑时先删除考评日期已经跑过的数据
        remove(new QueryWrapper<GovernanceAssessTecOwner>()
                .eq("assess_date", assessDate));

        List<GovernanceAssessTecOwner> governanceAssessTecOwners = governanceAssessTecOwnerMapper
                .calcAssessByTecOwner(assessDate);

        saveBatch(governanceAssessTecOwners);
    }
}
